package com.homeWork05;

public class consumption extends Thread {
    public static int stock = 10;
    private Lock lock;
    public consumption(Lock lock){
        this.lock=lock;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (lock) {
                if (stock > 10 || stock < 0) {
                    break;
                }
                stock--;
                System.out.println("消费取出1个单位货物，现在仓库剩余"+stock);
            }
        }
    }
}
